package com.ynu.springbootappdemo.model.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ynu.springbootappdemo.common.constant.UserConstant;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;
import java.util.Set;

@Entity
@Getter
@Setter
@NoArgsConstructor
@DiscriminatorValue(UserConstant.DEFAULT_ROLE)
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
public class Customer extends User{
    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
    @JoinColumn(name = "customer_id")
    @JsonIgnoreProperties("customer")
    private List<DeliveryAddress> deliveryAddresses;

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
    @JoinColumn(name = "customer_id")
    @JsonIgnoreProperties("customer")
    private Set<Orders> orders;
}
